package com.example.administrator.framework.sample;

import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

import com.example.administrator.framework.R;
import com.example.administrator.framework.constants.ConstantValues;
import com.example.administrator.framework.core.BaseActivity;

import static com.example.administrator.framework.core.BaseActivity.MODE_HOME;


/**
 * Created by Stay on 2/2/16.
 * Powered by www.stay4it.com
 */
public class HomeActivity extends BaseActivity implements View.OnClickListener {
    private Button mHomeProfileBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void setUpContentView() {
        setContentView(R.layout.activity_home, R.string.home_title, R.menu.menu_home, MODE_HOME);
    }

    @Override
    protected void setUpView() {
        mHomeProfileBtn = (Button) findViewById(R.id.mHomeProfileBtn);
        mHomeProfileBtn.setOnClickListener(this);
    }

    @Override
    protected void setUpData() {

    }


    @Override
    public void onClick(View v) {
        startActivity(new Intent(this, ProfileActivity.class));
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        int action = intent.getIntExtra(ConstantValues.KEY_HOME_ACTION, ConstantValues.ACTION_BACK_TO_HOME);
        switch (action) {
            case ConstantValues.ACTION_KICK_OUT:
                break;
            case ConstantValues.ACTION_LOGOUT:
                break;
            case ConstantValues.ACTION_RESTART_APP:
                protectApp();
                break;
            case ConstantValues.ACTION_BACK_TO_HOME:
                break;
        }
    }


    @Override
    public boolean onMenuItemClick(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.test1:
                startActivity(new Intent(this, SampleListActivity.class));
                break;
        }
        return true;
    }

    @Override
    protected void protectApp() {
        startActivity(new Intent(this, WelcomeActivity.class));
        finish();
    }

}
